package com.edu.control.deploy;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class PodResult implements Serializable {

    private Integer env;

    public Integer expectNum;

    public Integer runningNum = 0;

    public Integer unknownNum = 0;

    public Integer pendingNum = 0;

    public Integer succeededNum = 0;

    public Integer failedNum = 0;

    public Integer actualNum = 0;

    private Set<String> failedReason;

    private Set<String> unknownReason;

    private Set<String> pendingReason;

    public Integer getEnv() {
        return env;
    }

    public void setEnv(Integer env) {
        this.env = env;
    }

    public String getExpectNum() {
        return "预期服务数量：" + expectNum;
    }

    public void setExpectNum(Integer expectNum) {
        this.expectNum = expectNum;
    }

    public String getRunningNum() {
        return "正在运行数量：" + runningNum;
    }

    public void setRunningNum(Integer runningNum) {
        this.runningNum = runningNum;
    }

    public String getFailedNum() {
        return "服务重新部署数量：" + failedNum;
    }

    public void setFailedNum(Integer failedNum) {
        this.failedNum = failedNum;
    }

    public String getActualNum() {
        return "实际服务数量：" + actualNum;
    }

    public void setActualNum(Integer actualNum) {
        this.actualNum = actualNum;
    }

    public String getUnknownNum() {
        return "未知错误数量：" + unknownNum;
    }

    public String getPendingNum() {
        return "服务正在部署数量：" + pendingNum;
    }

    public String getSucceededNum() {
        return "一次性服务执行成功数量：" + succeededNum;
    }

    public void addFailedReason(String reason) {
        if (failedReason == null) {
            failedReason = new HashSet<>(4);
        }
        failedReason.add(reason);
    }

    public void addUnknownReason(String reason) {
        if (unknownReason == null) {
            unknownReason = new HashSet<>(4);
        }
        unknownReason.add(reason);
    }

    public void addPendIngReason(String reason) {
        if (pendingReason == null) {
            pendingReason = new HashSet<>(4);
        }
        pendingReason.add(reason);
    }

    public String getPendIngReason() {
        if (pendingReason == null) {
            return null;
        }
        return pendingReason.toString();
    }

    public String getFailedReason() {
        if (failedReason == null) {
            return null;
        }
        return failedReason.toString();
    }

    public String getUnknownReason() {
        if (unknownReason == null) {
            return null;
        }

        return unknownReason.toString();
    }


    @Override
    public String toString() {
        return "PodResult{" +
                "env=" + env +
                ", expectNum=" + expectNum +
                ", runningNum=" + runningNum +
                ", unknownNum=" + unknownNum +
                ", pendingNum=" + pendingNum +
                ", succeededNum=" + succeededNum +
                ", failedNum=" + failedNum +
                ", actualNum=" + actualNum +
                ", failedReason=" + failedReason +
                ", unknownReason=" + unknownReason +
                '}';
    }
}
